<script setup>
import { userInfoStore } from "@/stores/user.js";
import { getLikeListAPI } from "@/apis/user";
import { onMounted, ref } from "vue";
import GoodsItem from "@/views/Home/components/GoodsItem.vue";
import { getNewHotAPI } from "@/apis/home";

const likeList = ref([]);
const getLikeList = async () => {
  let res = await getNewHotAPI({ num: 4 });
  likeList.value = res.products;
};
onMounted(() => getLikeList());
const userStore = userInfoStore();
</script>

<template>
  <div class="home-overview">
    <!-- 用户信息 -->
    <div class="user-meta">
      <div class="avatar">
        <img :src="userStore.userInfo?.avatarUrl" />
      </div>
      <h4>{{ userStore.userInfo?.realName }}</h4>
    </div>
    <div class="item">
      <div style="display: flex; justify-content: center; align-items: center; gap: 10px">
        <el-icon :size="36" color="#fff"><CircleCheck /></el-icon>
        <!-- <span class="iconfont icon-hy"></span> -->
        <RouterLink to="/member/auth">权限验证</RouterLink>
        <!-- <p>会员中心</p> -->
      </div>
      <div style="display: flex; justify-content: center; align-items: center; gap: 10px">
        <el-icon :size="36" color="#fff"><WarnTriangleFilled /></el-icon>
        <!-- <span class="iconfont icon-aq"></span> -->
        <RouterLink to="/member/reportList">举报投诉</RouterLink>
      </div>
      <!-- <div style="display: flex; justify-content: center; align-items: center; gap: 10px">
        <el-icon :size="36" color="#fff"><ChatLineSquare /></el-icon>
        <RouterLink to="/member/feedback">意见反馈</RouterLink>
      </div> -->
      <!-- <span class="iconfont icon-dw"></span> -->
    </div>
  </div>
  <div class="like-container">
    <div class="home-panel">
      <div class="header">
        <h4 data-v-bcb266e0="">猜你喜欢</h4>
      </div>
      <div class="goods-list">
        <GoodsItem v-for="goods in likeList" :key="goods.productId" :goods="goods" />
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.home-overview {
  height: 132px;
  background: url(@/assets/images/center-bg.png) no-repeat center / cover;
  display: flex;

  .user-meta {
    flex: 1;
    display: flex;
    align-items: center;

    .avatar {
      width: 85px;
      height: 85px;
      border-radius: 50%;
      overflow: hidden;
      margin-left: 60px;

      img {
        width: 100%;
        height: 100%;
      }
    }

    h4 {
      padding-left: 26px;
      font-size: 18px;
      font-weight: normal;
      color: white;
    }
  }

  .item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-around;

    &:first-child {
      border-right: 1px solid #f4f4f4;
    }

    a {
      color: white;
      font-size: 16px;
      text-align: center;

      .iconfont {
        font-size: 32px;
      }

      p {
        line-height: 32px;
      }
    }
  }
}

.like-container {
  margin-top: 20px;
  border-radius: 4px;
  background-color: #fff;
}

.home-panel {
  background-color: #fff;
  padding: 0 20px;
  margin-top: 20px;
  height: 400px;

  .header {
    height: 66px;
    border-bottom: 1px solid #f5f5f5;
    padding: 18px 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;

    h4 {
      font-size: 22px;
      font-weight: 400;
    }
  }

  .goods-list {
    display: flex;
    justify-content: space-around;
  }
}
</style>
